Skip to content

feat: Add four more pattern geoms, test our geoms against {ggplot2}, and more with_pattern() methods - #170

Merged
trevorld merged 13 commits into
masterfrom
with-pattern-list
Nov 15, 2026
Merged

trevorld merged 13 commits into
masterfrom
with-pattern-list

Conversation

@trevorld

Copy link
Copy Markdown
Owner

Summary

New geoms (addresses #162)

Guarding against {ggplot2} changes (closes #163)

  • A test checks the rows we assume the areas of {ggplot2}'s geoms are drawn for (the known area_by of each geom and our shipped pattern geoms) against tracing. It is deliberately not skipped on CRAN so it also runs in {ggplot2}'s reverse dependency checks.
  • A test checks that our pattern geoms' default aesthetics (names and values), draw method arguments, other fields, and constructor arguments match their {ggplot2} counterparts. Its comment says what to do when it fails.
  • A new workflow runs R CMD check against the development {ggplot2} weekly (and on demand).
  • Fixes the drift these tests found: GeomTilePattern non_missing_aes and GeomSfPattern's default linetype.

with_pattern() and make_GeomPattern()

  • The grob a make_GeomPattern() geom draws is named after the geom (as {ggplot2} names its own).
  • with_pattern() returns any other {ggplot2} object (e.g. a coord or scale) as it is, so it can be given the list geom_sf() returns, and throws an error for a plot or a geom.
  • Requires {gridpattern} (>= 1.6.0-17) for its list and NULL methods.

Documentation

  • The developing-pattern-geoms vignette has a new section on using make_GeomPattern() in a package (a geom made at the top level stores a copy of the geom it was made from as of the package's build).
  • The README's table of geoms is now generated from the exported geom_*_pattern() functions and mentions with_pattern() / make_GeomPattern() for other geoms.

Testing

  • The last full R CMD check (clean) was at 7722081; the two commits since then were not re-checked. The test suite passed (708) before the final README and vignette prose edits.
  • The visual snapshot tests are all skip_on_ci() so they were only run locally. No new snapshots were added.
  • The scheduled workflow only starts running once it is on the default branch.

🤖 Generated with Claude Code

trevorld and others added 13 commits November 14, 2026 08:42
…against tracing (#163)

* For each geom in `known_area_by_geoms` (plus `GeomPoint`, `GeomMap`, and `GeomSf`)
  draws a layer whose areas all have different patterns and checks each area gets the same pattern
  from `make_GeomPattern()` with its known `area_by` and from our own pattern geom (if we have one)
  as from `area_by = "trace"` (which doesn't assume the order the geom draws its areas in).
* Also checks that tracing found the areas and that every geom in `known_area_by_geoms`
  and every exported `Geom*Pattern` has a spec.
* Not skipped on CRAN so it is also run by the reverse dependency checks of `{ggplot2}`.
* The `find_grobs()` test helper now looks within a `gList`
  (e.g. what `GeomSf` draws for a mix of geometry types).
* Bumps the version to v1.4.0-5.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* New `ggplot2-devel.yaml` workflow runs `R CMD check` with `github::tidyverse/ggplot2`
  every Monday (and on `workflow_dispatch`) for early warning of changes that break us
  e.g. to the order its geoms draw their areas in.
* The visual snapshot tests all `skip_on_ci()` so unrelated changes in how `{ggplot2}` draws don't fail it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ttern()`, `geom_dotplot_pattern()`, and `geom_hex_pattern()` (#162)

* `GeomContourFilledPattern` and `GeomDensity2dFilledPattern` are `GeomPolygonPattern` geoms
  (like their `{ggplot2}` counterparts are `GeomPolygon` geoms).
* `GeomHexPattern` and `GeomDotplotPattern` fill the areas of the grob their `{ggplot2}` counterpart draws
  with `with_pattern_aes()` (an area per row).
  The dots of a dotplot are only made when it is drawn so they are filled then (requires R (>= 4.2.0)).
* `geom_density2d_filled_pattern()` is an alias of `geom_density_2d_filled_pattern()`.
* The documentation examples that made pattern versions of `GeomContourFilled`
  now use `GeomSmooth` (which we don't have a pattern geom for).
* Also lists `geom_point_pattern()` in the README's table of geoms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…plot2}` counterparts

* For every exported `Geom*Pattern` checks its aesthetics, draw method arguments,
  and `required_aes`, `optional_aes`, `non_missing_aes`, and `rename_size` fields
  and for every exported `geom_*_pattern()` its arguments against those of its `{ggplot2}` counterpart.
  Skipped on CRAN (a mismatch means we should update ours, not a bug in the released package)
  but run by the scheduled check against the development `{ggplot2}`.
* `GeomTilePattern` (and so `GeomBin2dPattern`) now has the same `non_missing_aes` as `ggplot2::GeomTile`
  (found by the new test).
* `?make_GeomPattern` and the "Developing Pattern Geoms" vignette now say that a pattern geom
  made at the top level of a package's code stores a copy of the geom as it was when the package was built
  (so make it in `.onLoad()` or write its draw methods yourself)
  and that a hand-written pattern geom should be tested against the geom it extends.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…{ggplot2}`

* Update ours, skip the test for earlier `{ggplot2}` versions,
  and once that `{ggplot2}` is released bump the version we import and remove the skip.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* The grob its wrapped draw method returns is now named after the pattern geom
  (e.g. `"geom_smooth_pattern"` for `GeomSmoothPattern`) like `{ggplot2}` names the grobs of its geoms
  and like our own pattern geoms name theirs
  (so e.g. `with_pattern(geom_rect(key_glyph = "point"))` no longer draws an unnamed grob).
* Named from the class of the geom drawing it so a geom extending it gets its own name.
  A draw method result that isn't a single grob (e.g. a `gList`) is left alone.
* Copies `snake_class()` and `snakeize()` from `{ggplot2}`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t `geom_sf()` returns

* `gridpattern::with_pattern()`'s new `list` method passes each element of a list to `with_pattern()`
  so the list of a layer and a `coord_sf()` that `geom_sf()` returns needs a method for the coord.
  The new `Coord` method returns the coord as it is.
* Bumps the required `{gridpattern}` to v1.6.0-16.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…_pattern()` methods

* `?geom_histogram_pattern` and `?geom_dotplot_pattern` no longer document `bins` and `binwidth`
  with the text for contour bins: they (and `breaks`) are now documented for each geom that has them.
* The test of the rows we assume the areas of `{ggplot2}`'s geoms have
  (which isn't skipped on CRAN) no longer needs the suggested `{hexbin}`.
* The tests of the new geoms no longer check their arguments and aesthetics against `{ggplot2}`'s
  (a `{ggplot2}` change would have failed them on CRAN):
  the test of all our geoms (which is skipped on CRAN) already does.
  That test now uses the package's `ggproto_fn()`.
* `GeomDotplotPattern` and `GeomPointPattern` now throw an error if R is older than 4.2.0.
* New `with_pattern()` method for scales which (like that for coords) returns the scale as it is.
* Bumps the suggested `{testthat}` to v3.1.9 (for `expect_in()`).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…and throws an error for a plot

* A new `gg` method (replacing the `Coord` and `Scale` methods) returns any `{ggplot2}` object
  other than a layer as it is (e.g. a coord, scale, facet, theme, `labs()`, or `guides()`)
  so `with_pattern()` can be given a list of them and layers.
* A new `ggplot` method throws an error saying to give it the plot's layers instead.
* `?with_pattern.Layer` now says to make the pattern layer before applying a `{ggfx}` filter
  (`with_pattern(ggfx::with_blur(geom_col()))` is drawn without its patterns).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Its `with_pattern()` now returns `NULL` as it is so a list given to `with_pattern()` may have a `NULL`
  e.g. `with_pattern(list(geom_col(), if (flip) coord_flip()))`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* `GeomHexPattern` and `GeomDotplotPattern` get the default aesthetics of their `{ggplot2}` counterpart
  from it (like `GeomPointPattern`) instead of copying them.
* The tests share `our_pattern_geoms()` and `sf_square()` helpers and the specs that are the same,
  no longer check that `known_area_by()` gives a `{ggplot2}` geom the `area_by` it was just looked up with,
  and say which spec is pooled in the spec instead of by the geom's name.
* `check_r_version()` loses its unused `required` argument.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n()` takes its default `linetype` from the theme

* `with_pattern.Geom()` points to `make_GeomPattern()` instead of silently returning the geom.
* `GeomSfPattern`'s default `linetype` is now `from_theme(linetype)` to match `ggplot2::GeomSf`.
* The drift test now also compares the default aesthetic values against `{ggplot2}`'s.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…)` and `make_GeomPattern()` for other geoms

* The "Available Geoms" table is now generated from the exported `geom_*_pattern()` functions.
* Shorten the vignette's advice on what a hand-written pattern geom copies from the geom it extends.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@trevorld
trevorld merged commit e2864de into master Nov 15, 2026
3 checks passed
@trevorld
trevorld deleted the with-pattern-list branch November 15, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scheduled CI job checking pattern geoms against the development {ggplot2}

1 participant